package com.aistar.line.mapper;

import com.aistar.line.entity.Linespots;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Description: java类作用描述:对路线景点的crud
 * @Author: tyg
 * @CreateDate: 2019/6/27 0027
 * @Version: 1.0
 */
public interface LinespotsMapper {
    /**
     * 查询出旅游路线中所游玩的景点
     *
     * @param id
     * @return
     */
    @Select("select * from linespots where line_id = #{id}")
    List<Linespots> findByLineId(String id);

    /**
     * 根据路线id删除该路线所有景点
     *
     * @param id
     */
    @Delete("delete from linespots where line_id = #{id}")
    void delByLineId(String id);

    /**
     * 添加路线中的旅游景点
     *
     * @param sports
     */
    void save(@Param("sports") List<Linespots> sports);

    /**
     * 更新路线中的旅游景点
     * @param linespots
     * @param sid
     */
    @Update("update linespots set spot_id = #{linespots.spotId}  where lineSpots_id = #{sid}")
    void update(@Param("linespots") Linespots linespots, @Param("sid") String sid);

    /**
     * 根据景点id查询出关联的所有路线id
     * @param id
     * @return
     */
    @Select("select line_id from linespots where spot_id = #{id}")
    List<String> findBySpotId(String id);
}
